package com.mmg.cosplay.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 *
 * </p>
 *
 * @author mumangguo
 * @since 2024-11-26
 */
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@ToString
@Data
@Schema(description = "User对象")
@TableName("sys_user")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @NotBlank(message = "昵称不能为空")
    @Schema(description = "昵称")
    private String nickname;

    @NotBlank(message = "用户名不能为空")
    @Schema(description = "用户名")
    private String username;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @NotBlank(message = "密码不能为空")
    @Schema(description = "密码")
    private String password;

    @NotBlank(message = "性别不能为空")
    @Schema(description = "性别")
    private String sex;

    @NotNull(message = "年龄不能为空")
    @Schema(description = "年龄")
    private Integer age;

    @NotBlank(message = "头像不能为空")
    @Schema(description = "头像")
    private String avatar;

    @NotBlank(message = "手机号不能为空")
    @Schema(description = "手机号")
    private String phone;

    @NotBlank(message = "邮箱不能为空")
    @Schema(description = "邮箱")
    private String email;

    @Schema(description = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @JsonIgnore
    @TableLogic(value = "0", delval = "1")
    @Schema(description = "删除标记（0表示正常，1表示删除）")
    private Integer isDeleted;
}
